//引入封装的请求函数request
import request from '@/utils/request';
//引入相关返回值的类型
import type { resCategory, resAttr, attrDate } from '@/api/product/attr/type'
//属性管理模块的导出
enum API {
    //获取分类
    c1_URL = '/admin/product/getCategory1',
    c2_URL = '/admin/product/getCategory2',
    c3_URL = '/admin/product/getCategory3',
    //获取属性值
    attr_URL = '/admin/product/attrInfoList',
    //添加或修改已有属性的接口
    addOrUpdateAttr_URL = '/admin/product/saveAttrInfo',
    //删除已有属性的接口
    deleteAttr_URL = '/admin/product/deleteAttr/'
}

//获取一级分类的数据
export const reqc1 = () => request.get<any, resCategory>(API.c1_URL)
//获取二级分类的数据
export const reqc2 = (category1ID: number | string) => request.get<any, resCategory>(API.c2_URL + '/' + category1ID)
//获取三级分类的数据
export const reqc3 = (category2ID: number | string) => request.get<any, resCategory>(API.c3_URL + '/' + category2ID)
//获取属性的数据
export const reqAttr = (category1ID: number | string, category2ID: number | string, category3ID: number | string) => request.get<any, resAttr>(API.attr_URL + '/' + category1ID + '/' + category2ID + '/' + category3ID)
//添加或修改属性的数据
export const reqAddOrUpdateAttr = (data: attrDate) => request.post<any, any>(API.addOrUpdateAttr_URL, data)
//删除已有属性的数据
export const reqDeleteAttr = (id: number | string) => request.delete<any, any>(API.deleteAttr_URL + id)